package units
{
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	import projectiles.Purple_Projectile;
	public class Purple_Unit extends Unit
	{
		
		public function Purple_Unit(gH:GameHandler,c:Castle)
		{
			super.game_handler = gH;
			super.castle = c;
			
			unit_type = "purple_unit";
			range_line_style = 0xFF1FF0;
			
			this.attack_strength = 10;
			this.attack_radius = 500;
			this.attack_frequency = 50;
			
			game_handler.player_units.push(this);
			game_handler.addChild(this);

			this.addEventListener(MouseEvent.MOUSE_DOWN,super.select);
			
			show_range();
			hide_range();
		}
		override public function attack(){
			if(attack_counter < attack_frequency)
				return;
			var valid_targets = get_valid_targets();
			
			if(valid_targets.length != 0){
				attack_counter = 0;
				var p:Purple_Projectile = new Purple_Projectile(this,valid_targets[0],game_handler);
				valid_targets[0].virtual_hit("purple",this.attack_strength);
				p.set_attack_damage(this.attack_strength);
				p.set_speed(5);
			}
		}
	}
}